﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;
using Microhard.Plat.CRM.Stores.DataAccess;
using Microhard.Plat.CRM.Stores.Models;

namespace Microhard.Plat.CRM.Stores.DTO
{
    public static class FMCGServerMappingExtension
    {

        #region KA
        public static KAModel ToModel(this KA entity)
        {
            return Mapper.Map<KAModel>(entity);
        }

        public static KA ToEntity(this KAModel model)
        {
            return Mapper.Map<KA>(model);
        }
        #endregion

        #region SubKA
        public static SubKAModel ToModel(this SubKA entity)
        {
            var model = Mapper.Map<SubKAModel>(entity);
            model.KAName = entity.KA.Name;
            var nowMonth = DateTime.Now.Date.Month;
            return model;
        }

        public static SubKA ToEntity(this SubKAModel model)
        {
            return Mapper.Map<SubKA>(model);
        }
        #endregion

        #region CheckIn
        public static CheckinModel ToModel(this EmployeeCheckIn entity)
        {
            var model = Mapper.Map<CheckinModel>(entity);
            model.SubKA = entity.SubKA.ToModel();
            return model;
        }

        public static EmployeeCheckIn ToEntity(this CheckinModel model)
        {
            return Mapper.Map<EmployeeCheckIn>(model);
        }
        #endregion

        #region IspTemplate
        public static IspTemplateModel ToModel(this CheckListTemplate entity)
        {
            return Mapper.Map<IspTemplateModel>(entity);
        }

        public static CheckListTemplate ToEntity(this IspTemplateModel model)
        {
            return Mapper.Map<CheckListTemplate>(model);
        }
        #endregion

        #region IspCategory
        public static IspCategoryModel ToModel(this CheckListTemplateCategory entity)
        {
            var model = Mapper.Map<IspCategoryModel>(entity);
            model.TemplateName = entity.CheckListTemplate.TemplateName;
            return model;
        }

        public static CheckListTemplateCategory ToEntity(this IspCategoryModel model)
        {
            return Mapper.Map<CheckListTemplateCategory>(model);
        }
        #endregion

        #region IspItem
        public static IspItemModel ToModel(this CheckListTemplateItem entity)
        {
            var model = Mapper.Map<IspItemModel>(entity);
            model.CategoryName = entity.CheckListTemplateCategory.Name;
            model.TemplateName = entity.CheckListTemplateCategory.CheckListTemplate.TemplateName;
            return model;
        }

        public static CheckListTemplateItem ToEntity(this IspItemModel model)
        {
            return Mapper.Map<CheckListTemplateItem>(model);
        }
        #endregion

        #region IspTemplateAnswer
        public static IspTemplateAnswerModel ToModel(this CheckListTemplateAnswer entity)
        {
            var model = Mapper.Map<IspTemplateAnswerModel>(entity);
            model.ItemName = entity.CheckListTemplateItem.Name;
            return Mapper.Map<IspTemplateAnswerModel>(entity);
        }

        public static CheckListTemplateAnswer ToEntity(this IspTemplateAnswerModel model)
        {
            return Mapper.Map<CheckListTemplateAnswer>(model);
        }
        #endregion

        #region ProductDisplayImages
        public static ProductDisplayImageModel ToModel(this ProductDisplayImage entity)
        {
            return Mapper.Map<ProductDisplayImageModel>(entity); ;
        }

        public static ProductDisplayImage ToEntity(this ProductDisplayImageModel model)
        {
            return Mapper.Map<ProductDisplayImage>(model);
        }
        #endregion

    }
}
